package com.dindang.checkline.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.dindang.checkline.di.module.ErrorEndingModule;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.checkline.di.component.DaggerErrorEndingComponent;
import com.dindang.checkline.mvp.contract.ErrorEndingContract;
import com.dindang.checkline.mvp.presenter.ErrorEndingPresenter;

import com.dindang.checkline.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 03/26/2019 10:12
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class ErrorEndingActivity extends BaseActivity<ErrorEndingPresenter> implements ErrorEndingContract.View {
    ImageView mIvBack;
    TextView mTvTitle;
    TextView mTvCheckNumTip;
    RecyclerView mRecyclerView;
    TextView mTvCheckNum;
    EditText mEtRemark;
    TextView mButtonSbumit;
    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerErrorEndingComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .errorEndingModule(new ErrorEndingModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_error_ending; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.maintenance_iv_back);
        mTvTitle = findViewById(R.id.maintenance_tv_title);
        mTvCheckNumTip = findViewById(R.id.check_tv_number_pictures_tip_error);
        mRecyclerView = findViewById(R.id.maintenance_rv_pictures_error);
        mTvCheckNum = findViewById(R.id.maintenance_tv_pictures_remaining_amount_error);
        mEtRemark = findViewById(R.id.remark_et);
        mButtonSbumit = findViewById(R.id.button_submit);
        mTvTitle.setText("异常结束");
        mTvTitle.setOnClickListener(v -> finish());
        mIvBack.setOnClickListener(v -> finish());
        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public ImageView getIvBack() {
        return mIvBack;
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public TextView getTvCheckNumTip() {
        return mTvCheckNumTip;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return mRecyclerView;
    }

    @Override
    public TextView getTvCheckNum() {
        return mTvCheckNum;
    }

    @Override
    public EditText getEtRemark() {
        return mEtRemark;
    }

    @Override
    public TextView getButtonSbumit() {
        return mButtonSbumit;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }
}
